home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* DATABOSS MODULE: DB_CURS.C */
- /****************************************************************************/
-
- #include "db_lsc.h"
-
- #include <stdlib.h>
- #include <dos.h>
- #include "db_types.h"
- #include "db_curs.h"
- #ifdef __TURBOC__
- #include "db_dos.h"
- #include <conio.h>
- #else
- #include <graph.h>
- #endif
- #include "db_conio.h"
-
- /**************************** GLOBAL VARIABLES ****************************/
-
- bool ins_flag;
- cursortyp linecurs;
- cursortyp inscurs;
- cursortyp hidecurs;
- cursortyp origcurs;
-
- /*************************** INTERNAL VARIABLES ***************************/
-
- static bool initialized = False;
-
- /***************************** IMPLEMENTATION *****************************/
-
- void vidfun(int10_ah fun, modetyp *md)
- {
- union REGS regs;
-
- regs.h.ah = (byte) fun;
- switch (fun) {
- case _SetMode :
- regs.h.al = md->mode;
-
- /* swinterrupt(0x10,®s,®s); */
-
- int86(0x10, ®s, ®s);
- break;
- case _GetMode :
-
- /* swinterrupt(0x10,®s,®s); */
-
- int86(0x10, ®s, ®s);
- md->mode = regs.h.al;
- md->cols = regs.h.ah;
- md->dpage = regs.h.bh;
- break;
- }
- }
-
- void curfun(int10_ah fun, cursortyp *curs)
- {
- union REGS regs;
- modetyp m;
-
- vidfun(_GetMode,&m);
- regs.h.bh = m.dpage;
- regs.h.ah = (byte) fun;
- switch (fun) {
- case _SetCTyp :
- regs.h.ch = curs->b_scan;
- regs.h.cl = curs->e_scan;
-
- /* swinterrupt(0x10,®s,®s); */
-
- int86(0x10, ®s, ®s);
- regs.x.ax = regs.x.bx; /* this line was put into */
- break; /* pascal to hopefully fix a bug */
- case _SetCPos :
- gotoxy(curs->ccol, curs->crow);
- break;
-
- /*
- regs.h.dh = curs->crow - 1;
- regs.h.dl = curs->ccol - 1;
- swinterrupt(0x10,®s,®s);
- */
-
- case _GetCurs :
-
- /* swinterrupt(0x10,®s,®s); */
-
- int86(0x10, ®s, ®s);
- curs->b_scan = regs.h.ch;
- curs->e_scan = regs.h.cl;
- curs->crow = regs.h.dh + 1;
- curs->ccol = regs.h.dl + 1;
- break;
- }
- }
-
- void toggleins(cursortyp *curs)
- {
- ins_flag = (bool) (!ins_flag);
- if (ins_flag) {
- curs->b_scan = inscurs.b_scan;
- curs->e_scan = inscurs.e_scan;
- curfun(_SetCTyp,curs);
- }
- else {
- curs->b_scan = linecurs.b_scan;
- curs->e_scan = linecurs.e_scan;
- curfun(_SetCTyp,curs);
- }
- }
-
- /********************** UNIT INITIALIZATION/EXIT CODE *********************/
-
- void db_curs_exit(void)
- {
- curfun(_SetCTyp,&origcurs);
- }
-
- void db_curs_init(void)
- {
- if (!initialized) {
- initialized = True;
- ins_flag = False;
- curfun(_GetCurs,&origcurs);
- linecurs = origcurs;
- inscurs = origcurs;
- inscurs.b_scan = 0;
- hidecurs = origcurs;
- hidecurs.b_scan = hidecurs.b_scan | 0x30;
- atexit(db_curs_exit);
- }
- }
-
- /**************************** END OF DB_CURS.C ****************************/
-